package com.xuanwei.core.entity.vo;

import com.xuanwei.core.enums.OrderStatus;
import com.xuanwei.core.enums.RefundStatus;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Author jiangyong
 * @Description TODO
 * @Date 2019/7/16 16:17
 **/
@Data
public class OrderVo {

    private Integer id;

    private String orderNo;

    /**
     * 实际支付金额
     */
    private BigDecimal actualAmount;

    /**
     * 状态0未支付1已支付2已发货3已收货4已评价5售后6已关闭
     */
    private Integer status;

    /**
     * 退款状态
     */
    private Integer refundStatus;

    private String refundStatusMsg;

    public String getRefundStatusMsg() {
        return RefundStatus.getMessage(refundStatus);
    }

    private List<OrderItemVo> orderItemVos;


    private String statusMsg;

    private Integer count;

    public Integer getCount() {
        return orderItemVos.stream().mapToInt(OrderItemVo::getCount).sum();
    }

    public String getStatusMsg() {
        return OrderStatus.getMessage(status);
    }

    @Data
    public static class OrderItemVo {

        private Integer id;

        private String productName;

        private Integer count;

        private String skuName;

        private String image;

        private BigDecimal price;
    }

}
